package com.zwd.deep.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zwd.deep.entity.dto.DiagnosisDto;
import com.zwd.deep.entity.po.Diagnoses;
import com.zwd.deep.entity.vo.DiagnosesVo;
import com.zwd.deep.mapper.DiagnosesMapper;
import com.zwd.deep.service.IDiagnosesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 诊断记录表 服务实现类
 * </p>
 *
 * @author zwd
 * @since 2025-02-12
 */
@Service
public class DiagnosesServiceImpl extends ServiceImpl<DiagnosesMapper, Diagnoses> implements IDiagnosesService {
    @Autowired
    private DiagnosesMapper diagnosesMapper;

    @Override
    public List<DiagnosesVo> getDiagnosisRecords(Integer userId) {
        List<DiagnosesVo> diagnosesVoList = diagnosesMapper.selectListByUserId(userId);
        return diagnosesVoList;
    }

    @Override
    public Integer addDiagnosis(DiagnosisDto diagnosisDto) {
        Diagnoses diagnoses = new Diagnoses();
        BeanUtil.copyProperties(diagnosisDto, diagnoses);
        diagnosesMapper.insert(diagnoses);
        Integer diagnosisId = diagnoses.getDiagnosisId();
        return diagnosisId;
    }
}
